package com.laguille.games.monopoly.commons.event;

import org.apache.commons.lang.Validate;

import com.laguille.games.monopoly.commons.player.Player;

/**
 * This event is emitted when a player wants to terminate his turn but could not.
 * This is because the player cash balance is in the red.
 *
 */

public class UnfinishedTurnEvent extends Event {

	private final Player currentPlayer;
	
	public UnfinishedTurnEvent(Player currentPlayer)  {
		Validate.notNull(currentPlayer);
		this.currentPlayer = currentPlayer;
	}


	/**
	 * @return the currentPlayer
	 */
	public Player getCurrentPlayer() {
		return currentPlayer;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((currentPlayer == null) ? 0 : currentPlayer.hashCode());
		return result;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UnfinishedTurnEvent other = (UnfinishedTurnEvent) obj;
		if (currentPlayer == null) {
			if (other.currentPlayer != null)
				return false;
		} else if (!currentPlayer.equals(other.currentPlayer))
			return false;
		return true;
	}


	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "UnfinishedTurnEvent [currentPlayer=" + currentPlayer + "]";
	}

}
	
